unit dmda_Supply;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, dmModule, DB, FR_DSet, FR_DBSet, ADODB;

type
  Tdtmda_Supply = class(TdtmModule)
    adsMasterCountry: TStringField;
    adsMasterLinkMan: TStringField;
    adsMasterAddress: TStringField;
    adsMasterTel: TStringField;
    adsMasterFax: TStringField;
    adsMasterEmail: TStringField;
    adsMasterHomePage: TStringField;
    adsMasterTaxNo: TStringField;
    adsMasterAccounts: TStringField;
    adsMasterKindID: TStringField;
    adsMasterPhoneNo: TStringField;
    adsMasterSettleID: TStringField;
    res_Currency: TADODataSet;
    adsMasterKindIDName: TStringField;
    adsSupplyType: TADODataSet;
    adsMasterKindNo: TStringField;
    res_BaseInfo: TADODataSet;
    adsMasterEditCountry: TStringField;
    adsMasterEditLinkMan: TStringField;
    adsMasterEditAddress: TStringField;
    adsMasterEditTel: TStringField;
    adsMasterEditFax: TStringField;
    adsMasterEditEmail: TStringField;
    adsMasterEditHomePage: TStringField;
    adsMasterEditTaxNo: TStringField;
    adsMasterEditAccounts: TStringField;
    adsMasterEditKindID: TStringField;
    adsMasterEditPhoneNo: TStringField;
    adsMasterEditSettleID: TStringField;
    adsMasterEditHasUse2: TBooleanField;
    adsMasterEditHasStop2: TBooleanField;
    adsMasterEditRemark2: TStringField;
    adsMasterEditStopDate: TDateTimeField;
    adsMasterEditStoper2: TStringField;
    adsMasterEditStopMemo2: TStringField;
    adsMasterEditWriter2: TStringField;
    adsMasterEditWriteTime2: TDateTimeField;
    adsMasterEditModifyTime2: TDateTimeField;
    adsMasterEditModifier2: TStringField;
    adsMasterEditHasCheck2: TBooleanField;
    adsMasterEditCheckTime2: TDateTimeField;
    adsMasterEditChecker2: TStringField;
    adsMasterEditHasSysDefine: TBooleanField;
    adsMasterEditHasDefault: TBooleanField;
    adsMasterHelperCode: TStringField;
    adsMasterPostCode: TStringField;
    adsMasterCorporator: TStringField;
    adsMasterSettleName: TStringField;
    adsMasterCurrencyID: TStringField;
    adsMasterCurrencyName: TStringField;
    adsMasterBankName: TStringField;
    adsMasterBankDoor: TStringField;
    adsMasterEditHelperCode: TStringField;
    adsMasterEditPostCode: TStringField;
    adsMasterEditCorporator: TStringField;
    adsMasterEditCurrencyID: TStringField;
    adsMasterEditBankName: TStringField;
    adsMasterEditBankDoor: TStringField;
    adsMasterHasStop: TBooleanField;
    adsMasterHasUse: TBooleanField;
    adsMasterHasSysDefine: TBooleanField;
    adsMasterHasDefault: TBooleanField;
    adsMasterStoper: TStringField;
    adsMasterStopDate: TDateTimeField;
    adsMasterStopMemo: TStringField;
    adsMasterHasCheck: TBooleanField;
    adsMasterChecker: TStringField;
    adsMasterCheckTime: TDateTimeField;
    adsMasterWriter: TStringField;
    adsMasterWriteTime: TDateTimeField;
    adsMasterModifier: TStringField;
    adsMasterModifyTime: TDateTimeField;
    adsMasterRemark: TStringField;
    adsMasterEditres_CurrencyName: TStringField;
    adsMasterEditres_SettleName: TStringField;
    adsMasterEditres_KindName: TStringField;
    adsMasterEditSupplyID: TStringField;
    adsMasterEditSupplyCode: TStringField;
    adsMasterEditSupplyShortName: TStringField;
    adsMasterEditSupplyFullName: TStringField;
    adsMasterSupplyID: TStringField;
    adsMasterSupplyCode: TStringField;
    adsMasterSupplyShortName: TStringField;
    adsMasterSupplyFullName: TStringField;
    res_item: TADODataSet;
    adsSupplyTypeID: TStringField;
    adsSupplyTypeRuleChildID: TStringField;
    adsSupplyTypeCode: TStringField;
    adsSupplyTypeName: TStringField;
    adsSupplyTypeFullName: TStringField;
    adsUserCompany: TADODataSet;
    adsMasterEditDeptID: TStringField;
    adsMasterDeptID: TStringField;
    adsMasterEditItemContent: TStringField;
    procedure adsMasterEditNewRecord(DataSet: TDataSet);
    procedure adsMasterEditSupplyShortNameChange(Sender: TField);
  private
    { Private declarations }
  protected
    procedure ModuleInit;override;
    procedure OpenEditDataSet; override;
  public
    { Public declarations }
    FSupplyType: string;
  end;

var
  dtmda_Supply: Tdtmda_Supply;

implementation
       uses uGlobal,uMsgBox,uShare, uConst, uSQL, dmConnect;
{$R *.dfm}

{ Tdtmda_Supply }

procedure Tdtmda_Supply.ModuleInit;
begin
  FUniqueTable := 'da_Supply';
  inherited;
end;  

procedure Tdtmda_Supply.OpenEditDataSet;
begin
  FMasterEditTable := 'da_Supply';
  FMasterKeyField := 'SupplyID';
  inherited;
end;

procedure Tdtmda_Supply.adsMasterEditSupplyShortNameChange(Sender: TField);
begin
  inherited;
  if adsMasterEdit.State in [dsInsert, dsEdit] then
  begin
    adsMasterEdit.FieldByName('HelperCode').AsString :=
      GetHzPy(adsMasterEdit.FieldByName('SupplyShortName').AsString);
  end;
end;

procedure Tdtmda_Supply.adsMasterEditNewRecord(DataSet: TDataSet);
begin
  inherited;
  if (adsMasterEdit.State in [dsInsert, dsEdit]) and (FSupplyType<>'') then
  begin
    adsMasterEdit.FieldByName('KindID').ReadOnly := False;
    adsMasterEdit.FieldByName('KindID').AsString := FSupplyType;
  end;
end;

end.

